7.3 How to input data?

  1. Motivations
  2. How to read user inputs?
    • Usually within a form, e.g., <form> ... </form>. Note that the sumission of data to a server will be discussed next time.
    • What elements within a form can be used to read data from the user?
      • Try all the examples in HTML Forms.
      • Trial 1: Let's try to read data from the user.


      • Try all the examples in HTML Form Elements.
      • input
        • Try all the examples in HTML Input Types.
        • type: text, password, hidden, submit, email, ...
        • name
        • value
        • autocomplete
        • autofocus
        • readonly, disabled, size, maxlength, ...
        • Try all the examples in HTML Input Attributes.
        • When do you use 'hidden'?
        • Trial 2: Let's try to read command, username and password.


        • Trial 3: Let's try to submit command, username and password to a server-side program. Note that the 'value's are submitted with their 'name's, not 'id's.


      • select and option
      • Trial 4: Let's try to read the selected option.


      • textarea
      • radio
        • How to group multiple radio buttons so that only one can be checked?    the same name value
      • checkbox
      • button
      • datalist
    • Just a question. Do you remember how to select elements using attributes in CSS? If you do not remember, study CSS Attribute Selectors.
    • Trial 5: Let's try to write the code to read username, password, and note from the user, when a button is clicked. For each input-like element, you can read 'name' and 'value' values. (Think for what you use


  3. How to automatically fill in an input field?
  4. How to hide user typing?

  5. Learning outcomes